You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(presence): unmount timer-only zero-duration exits in the same flush - #1161
Snapshot exitDuration when a timer-only exit starts (!options.animations) inside the existing transition memo in packages/presence/src/index.ts, adding no extra memo slots.
Derive isMounted() and isExiting() as false in the same reactive flush when that sampled timer-only exit duration is <= 0, instead of scheduling setTimeout(finishExit, exitDuration()).
For immediate exits, fire onExited from the exit effect without writing reactive state (avoiding EFFECT_WRITES_OWN_SOURCE and EFFECT_RELAY_TEAR), preserve the onFlush unmount-before-remount gap on item swaps, and guard finishExit against duplicate completion from done().
Keep animations: true with transitionDuration: 0 observing getAnimations() when the element is observable.
Add regression tests in packages/presence/test/createPresence.test.ts, a renderHydrationRoundTrip() test in packages/presence/test/hydration.test.tsx, and a patch changeset for @solid-primitives/presence.
Happy to adjust if maintainers prefer keeping the 1-tick exit state or another approach discussed in #1160.
Verification
Before the fix: reproduced separately on published @solid-primitives/presence@1.1.0 (solid-js@2.0.4) and on main (b879b1f960ec, unmodified packages/presence/src/index.ts tested in Linux Docker node:24 with the two client test files failing 4 failed | 63 passed (67)).
After the fix (Linux node:22v22.23.5, pnpm install --frozen-lockfile):
pnpm --filter @solid-primitives/presence test -- --run passed (3 test files, 68 passed, including test/hydration.test.tsxrenderHydrationRoundTrip(), all 4 reactivity diagnostic scenarios, and the observable-animation regression)
pnpm run verify:manifests, pnpm run test:scripts (9 passed), pnpm run check:peer-major, pnpm lint (0 errors), pnpm format:check, and pnpm run jsr:sync-versions:check passed
Not run locally: full monorepo pnpm test across unrelated packages and jsr-ci.yml Deno commands (deno.jsonc untouched).
Summary by CodeRabbit
Bug Fixes
Zero-duration exits now unmount in the same reactive update, avoiding a brief delay.
Exit timing is sampled when an exit begins, and detected animations can complete even when the transition duration is zero.
Improved handling of item swaps and hydration with zero-duration transitions.
No actionable comments were generated in the recent review.
Walkthrough
Timer-only presence exits with nonpositive sampled durations now unmount in the same reactive flush. Exit completion uses a shared helper. Tests cover exit timing, item replacement, animation completion, and hydration.
Changes: Presence exit timing
Layer / File(s)
Summary
Sample exit duration and complete exits packages/presence/src/index.ts
The transition record captures the exit duration when an exit begins. Timer-only exits with nonpositive durations become unmounted immediately. Timer and animation completion use a shared helper that prevents duplicate completion and calls onExited.
Test exit timing and hydration packages/presence/test/createPresence.test.ts, packages/presence/test/hydration.test.tsx, .changeset/presence-zero-duration-exit.md
Tests cover same-flush unmounting, item replacement, sampled accessor durations, animation completion, and hydration. The changeset declares a patch release.
Timer-only presence exits with a zero or negative duration now unmount in the same reactive flush, which removes the brief overlap of outgoing and incoming panels. Animation-aware exits and item-swap ordering are preserved, and regression and hydration tests cover the change. No remaining merge-blocking risk is evident.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the primary change: timer-only exits with a zero or nonpositive duration now unmount in the same reactive flush. The changeset, the index.ts change (nonpositive sampled duration treate…
Linked Issues check
#1160 requires that, in timer-only mode (no animations: true), an exit with sampled duration <= 0 unmounts in the same reactive flush. The diff to packages/presence/src/index.ts implements this. T…
Out of Scope Changes check
All changed files relate to #1160. index.ts changes implement the same-flush exit, the onExited notification, the finishExit guard, and the createPresence doc note on nonpositive timer-only ex…
Full details: Title check
Explanation
The title names the primary change: timer-only exits with a zero or nonpositive duration now unmount in the same reactive flush. The changeset, the index.ts change (nonpositive sampled duration treated as immediate unmount), and the tests all match this. The title uses the conventional fix(presence) form and is specific, so it passes.
Full details: Linked Issues check
Explanation
#1160 requires that, in timer-only mode (no animations: true), an exit with sampled duration <= 0 unmounts in the same reactive flush. The diff to packages/presence/src/index.ts implements this. The transition memo samples exitDuration() at source change when options.animations is falsy. isMounted returns false when source() is false and the sampled duration is <= 0, so no setTimeout is scheduled. The exit effect calls onExited directly and writes no signal, which avoids the EFFECT_WRITES_OWN_SOURCE and EFFECT_RELAY_TEAR diagnostics. For animations: true, the path still calls settleAnimations on observable elements with the sampled or current duration, so the getAnimations() wait is kept. finishExit guards duplicate completion per generation, and done() routes through it, so the timer and done() cannot both complete one exit. Regression tests and a hydration round-trip test are reported in the PR description. I did not run them. The test files were not inspected in this review, so the test coverage verdict rests on the PR description and the source diff.
Full details: Out of Scope Changes check
Explanation
All changed files relate to #1160. index.ts changes implement the same-flush exit, the onExited notification, the finishExit guard, and the createPresence doc note on nonpositive timer-only exits. The shortened onExited doc comment and the generation to transition rename describe the same mechanism. The test files cover the zero-duration, item-swap, diagnostics, and observable-animation cases that the issue names. The hydration test covers the same zero-duration path. The changeset is a patch for @solid-primitives/presence. No unrelated behavior change appears in the diff. The test file contents were not read in this review.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 706c0627-fa8b-49fb-b40c-3a7d95a7033f
Commits
Reviewing files that changed from the base of the PR and between b879b1f and 74c6fef.
Files selected for processing: 4
.changeset/presence-zero-duration-exit.md
packages/presence/src/index.ts
packages/presence/test/createPresence.test.ts
packages/presence/test/hydration.test.tsx
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1160.
Summary
exitDurationwhen a timer-only exit starts (!options.animations) inside the existingtransitionmemo inpackages/presence/src/index.ts, adding no extra memo slots.isMounted()andisExiting()asfalsein the same reactive flush when that sampled timer-only exit duration is<= 0, instead of schedulingsetTimeout(finishExit, exitDuration()).onExitedfrom the exit effect without writing reactive state (avoidingEFFECT_WRITES_OWN_SOURCEandEFFECT_RELAY_TEAR), preserve theonFlushunmount-before-remount gap on item swaps, and guardfinishExitagainst duplicate completion fromdone().animations: truewithtransitionDuration: 0observinggetAnimations()when the element is observable.packages/presence/test/createPresence.test.ts, arenderHydrationRoundTrip()test inpackages/presence/test/hydration.test.tsx, and a patch changeset for@solid-primitives/presence.Happy to adjust if maintainers prefer keeping the 1-tick exit state or another approach discussed in #1160.
Verification
@solid-primitives/presence@1.1.0(solid-js@2.0.4) and onmain(b879b1f960ec, unmodifiedpackages/presence/src/index.tstested in Linux Dockernode:24with the two client test files failing4 failed | 63 passed (67)).node:22v22.23.5,pnpm install --frozen-lockfile):pnpm --filter @solid-primitives/presence buildpassedpnpm --filter @solid-primitives/presence test -- --runpassed (3test files,68 passed, includingtest/hydration.test.tsxrenderHydrationRoundTrip(), all 4 reactivity diagnostic scenarios, and the observable-animation regression)pnpm --filter @solid-primitives/presence test:ssr -- --runpassed (3 passed)pnpm run verify:manifests,pnpm run test:scripts(9 passed),pnpm run check:peer-major,pnpm lint(0errors),pnpm format:check, andpnpm run jsr:sync-versions:checkpassedpnpm testacross unrelated packages andjsr-ci.ymlDeno commands (deno.jsoncuntouched).Summary by CodeRabbit